package com.flx.noodle.websocket.dao.mapper;

import com.flx.noodle.websocket.entity.ChatMessage;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by fenglixiong on 2017/10/2.
 */
public class MessageRowMapper implements RowMapper<ChatMessage> {
    public ChatMessage mapRow(ResultSet resultSet, int i) throws SQLException {
        ChatMessage chatMessage = new ChatMessage();
        chatMessage.setId(resultSet.getInt("id"));
        chatMessage.setChatId(resultSet.getInt("chat_id"));
        chatMessage.setUserId(resultSet.getInt("user_id"));
        chatMessage.setUserName(resultSet.getString("user_name"));
        chatMessage.setCreateTime(resultSet.getTimestamp("create_time"));
        chatMessage.setContent(resultSet.getString("content"));
        chatMessage.setContentSize(resultSet.getInt("content_size"));
        chatMessage.setContentType(resultSet.getString("content_type"));
        return chatMessage;
    }
}
